﻿@model Contrib.DecoratorField.ViewModels.DecoratorFieldViewModel
@using Contrib.DecoratorField.Settings;

@{ 
    string wtag = "<";
    switch (Model.Settings.HtmlTag)
    {
        default:
            {
                wtag = wtag + Model.Settings.HtmlTag.ToString();
                if (Model.Settings.Mode != DecoMode.end )
                {
                    if (Model.Settings.HasAttributes && !string.IsNullOrEmpty(Model.Settings.Attributes))
                    {
                        wtag = wtag + " " + Model.Settings.Attributes;
                    }
                    if (!string.IsNullOrEmpty(Model.Settings.CssClass))
                    {
                        wtag = wtag + " class='" + Model.Settings.CssClass+"'";
                    }
                    if ( Model.Settings.Mode == DecoMode.full )
                    {
                        if(Model.Settings.HasContent)
                        {
                            wtag = wtag + " >" + Model.Settings.TagContent + "</" + Model.Settings.HtmlTag.ToString()+">";
                        }
                        else
                        {
                            wtag = wtag + " />";
                        }
                    }
                    else
                    {
                        if (Model.Settings.HasContent)
                        {
                            wtag = wtag + " >" + Model.Settings.TagContent;
                        }
                        else
                        {
                            wtag = wtag + " >";   
                        }                        

                    }
                }
                else
                {
                    wtag = wtag + "/" + Model.Settings.HtmlTag.ToString() + ">";
                }
            }
            break;
        case HtmlTagDisplay.br:
            wtag = wtag + "br/>";
            break;
    }

}
@Html.Raw(wtag)

